import { request } from '@/utils/request'

export interface PaymentParams {
  orderId: string
  paymentMethod: 'wechat' | 'balance'
}

export interface PaymentResult {
  code: number
  message: string
  data?: {
    timeStamp?: string
    nonceStr?: string
    package?: string
    signType?: string
    paySign?: string
  }
}

export const payOrder = (params: PaymentParams) => {
  return request<PaymentResult>({
    url: '/api/payment/pay',
    method: 'POST',
    data: params
  })
}

export const getPaymentStatus = (orderId: string) => {
  return request<PaymentResult>({
    url: `/api/payment/status/${orderId}`,
    method: 'GET'
  })
}